/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apli.haiam.ejb.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Informática
 */
@Entity
@Table(name = "adm_rol")
@NamedQueries({
    @NamedQuery(name = "AdmRol.findAll", query = "SELECT a FROM AdmRol a")})
public class AdmRol implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_rol")
    private Short idRol;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 128)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinTable(name = "adm_rol_accion", joinColumns = {
        @JoinColumn(name = "id_rol", referencedColumnName = "id_rol")}, inverseJoinColumns = {
        @JoinColumn(name = "id_accion", referencedColumnName = "id_accion")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<AdmAccion> admAccionList;
    @JoinTable(name = "adm_usuario_rol", joinColumns = {
        @JoinColumn(name = "id_rol", referencedColumnName = "id_rol")}, inverseJoinColumns = {
        @JoinColumn(name = "id_usuario", referencedColumnName = "id_usuario")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<AdmUsuario> admUsuarioList;
    @JoinColumn(name = "id_sistema", referencedColumnName = "id_sistema")
    @ManyToOne(fetch = FetchType.LAZY)
    private AdmSistema admSistema;

    public AdmRol() {
    }

    public AdmRol(Short idRol) {
        this.idRol = idRol;
    }

    public AdmRol(Short idRol, String nombre) {
        this.idRol = idRol;
        this.nombre = nombre;
    }

    public Short getIdRol() {
        return idRol;
    }

    public void setIdRol(Short idRol) {
        this.idRol = idRol;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<AdmAccion> getAdmAccionList() {
        return admAccionList;
    }

    public void setAdmAccionList(List<AdmAccion> admAccionList) {
        this.admAccionList = admAccionList;
    }

    public List<AdmUsuario> getAdmUsuarioList() {
        return admUsuarioList;
    }

    public void setAdmUsuarioList(List<AdmUsuario> admUsuarioList) {
        this.admUsuarioList = admUsuarioList;
    }

    public AdmSistema getAdmSistema() {
        return admSistema;
    }

    public void setAdmSistema(AdmSistema admSistema) {
        this.admSistema = admSistema;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRol != null ? idRol.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AdmRol)) {
            return false;
        }
        AdmRol other = (AdmRol) object;
        if ((this.idRol == null && other.idRol != null) || (this.idRol != null && !this.idRol.equals(other.idRol))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.apli.haiam.ejb.entidades.AdmRol[ idRol=" + idRol + " ]";
    }
    
}
